import React from 'react'
import { createBrowserRouter, RouterProvider, useNavigate } from 'react-router-dom'//history模式的路由
import Home from './pages/Home'
import About from './pages/About'
import Layout from './pages/Layout'
import KeepAlive from './KeepAlive'

const routes = [
  {
    path: '/',
    element: <Layout />,
    children: [
      {
        path: '/home',
        element: <Home />,
      },
      {
        path: '/about',
        element: <About />,
      },
    ],
  }
]
const router = createBrowserRouter(routes)

export default function App() {
  return (
    <div>
      <KeepAlive keepPath={['/home']}>
        <RouterProvider router={router} />
      </KeepAlive>
    </div>
  )
}
